<?php
## include config & db info ##
include $_SERVER['DOCUMENT_ROOT']."/pos/lib/list.php";

## include HTML view header ##
include $_SERVER['DOCUMENT_ROOT']."/pos/lib/head_view.php";

## include SQL header ##
include $_SERVER['DOCUMENT_ROOT']."/pos/lib/array_sql.php";

$pagediv	= $_POST['page'];
$scale		= $_POST['scale'];
if($scale==0){
	$scale		= 10;
}

if($_POST['mode']=='search'){
	if($_POST['sear_char']){
	$value = trim($_POST['sear_char']);
	$sear_char = 
	" 
	AND usercode	 LIKE '%$value%'
	OR name		 LIKE '%$value%'
	OR namekana	 LIKE '%$value%'
	OR zip		 LIKE '%$value%'
	OR addr1	 LIKE '%$value%'
	OR addr2	 LIKE '%$value%'
	OR addr3	 LIKE '%$value%'
	OR addr4	 LIKE '%$value%'
	OR tel		 LIKE '%$value%'
	OR phone	 LIKE '%$value%'
	OR fax		 LIKE '%$value%'
	OR email	 LIKE '%$value%'
	OR job		 LIKE '%$value%'
	OR mw 		 LIKE '%$value%'
	OR age		 LIKE '%$value%'
	OR birth	 LIKE '%$value%'
	OR writeday	 LIKE '%$value%'
	";
	}
}


## 고객 마스터 테이블
#  uatp_customer
$query	= sprintf(posSql('customer_info_view'), $sear_char, 'desc');//"select * from uatp_product where 1 $sear_char order by no DESC ";
$total	= DBnumrows($query);

## 페이지  출력하기(파라미터 : 한 페이지에 나타날 row 개수)
$page = page_division($scale,$total,$pagediv);	// 10개

## 고객 마스터 테이블 페이지로 나누기
$query	= sprintf(posSql('customer_info_view_page'),$sear_char, $page['cline'], $page['scale1']);//"select * from uatp_product where 1 $sear_char order by no DESC LIMIT $cline, $scale1";
$result	= DBquery($query);

if($page['totalpage']==0){
	$page['totalpage'] = 1;
}
?>


<body>

<script>
$(document).ready(function(){
$("div#menu-content").slideUp(0);
	$("img#sear_close").click(function(){
		$("div#menu-content").slideUp(800);
	$("img#sear_open").css('visibility', 'visible');
	$("img#sear_close").css('visibility', 'hidden');
	});
	
	$("img#sear_open").click(function(){
		$("div#menu-content").slideDown(800);
	$("img#sear_close").css('visibility', 'visible');
	$("img#sear_open").css('visibility', 'hidden');
	});
});

$(function() {
	$("#pager").paginate({
		count 		: <?=$page['totalpage']?>,
		start 		: <?=$page['cpage']?>,
		display     : 10,
		border					: true,
		border_color			: '#A2A2A2',
		text_color  			: '#444',
		background_color    	: '#FFF',	
		text_hover_color  		: 'black',	
		background_hover_color	: '#CFCFCF',
		border_hover_color		: '#AFAFAF',
		images					: false,
		mouse					: 'press',
		onChange     			: function(page){
									document.view.page.value = page;
									search();
								  }
	});
});

function search(){
	document.view.mode.value = 'search';
	document.view.target = 'right';
	document.view.action = 'view.php';
	document.view.method = 'post';
	document.view.submit();
}
</script>
	<div style="width: 100%; margin: 0; paddin: 0;">
		<ul id="breadcrumb">
			<li><a href="#" title="Home"><img src="../../../image/home.png"
					alt="Home" class="home" /> </a></li>
			<li><a href="#">고객 관리</a></li>
			<li>고객 정보 마스터</li>
		</ul>
<!-- 상세검색 폼 -->
			<!--  div id="menu-content" style="visibility: visible;">
				<div class="menu-mine" id="menu-mine">
					<div class="menus" id="menus"
						style="overflow: hidden; height: 100px; position: relative; z-index: 2;">
						<div class="menus_view" id="menu_move"	style="position: relative; z-index: 1">
!--		 여기에 search form 들어갈 자리		 --
							
!--		여기까지 search form 들어갈 자리		 --
						</div>
					</div>
				</div>
				<div style="text-align: center; width: 100%;">
				<img src="../../../image/sear_close.gif" id="sear_close"></img>
				</div>
			</div>
			
		<div style="text-align: center; width: 100%; height: 40px; background: url(../../../image/mn_line.gif) repeat-x;">
			<img src="../../../image/sear_open.gif" id="sear_open"></img>
		</div>
<!--// 상세검색 폼 -->		
		
		<form name="view" method="post" id="view" action="javascript:search();">
				<input type="hidden" value="" name="mode" />
				<input type="hidden" value="" name="page" />
				<div style="float: left; padding: 0; margin: 0; width: 100%; background: #efefef; border-top: 1px solid #e2e2e2;">
				<span style="float: left; padding-left: 15px; height: 30px; line-height: 30px;">
					<a href="javascript:customer_delete();" class="button white small">&nbsp;삭제하기&nbsp;</a>
					<a href="javascript:customer_modify();" class="button white small">&nbsp;수정하기&nbsp;</a>
					<a href="insert.php" class="button green small">&nbsp;입력하기&nbsp;</a>
				</span> 
				
				<span style="float: right;valign:bottom; padding-right: 15px; color: #999;padding-top:5px">

				</span>
			</div>

			<table class="tablesorter">
				<tr>
					<th width="10px"><input
						onclick="if (this.checked) all_checked(true); else all_checked(false);"
						type=checkbox tabindex=1 name=chk_head />
					</th>
					<th width="30px">code</th>
					<th>이름</th>
					<th>전화번호</th>
					<th>휴대폰</th>
					<th>Fax</th>
					<th>주소</th>
					<th>E-mail</th>
					<th>직업</th>
					<th>성별</th>
				</tr>
				<?
				## 고객 마스터 테이블 출력
				for($i=1; $list = mysql_fetch_array($result); $i++){
					if($i%2!=0){
						echo "<tr class='odd'>";
					}else{
						echo "<tr class='even'>";
					}
					?>
				<td onclick="javascript:chk(<?=$list[Idx]?>)"><input type=checkbox
					name=chk_no[] value="<?=$list['Idx']?>"
					onclick="javascript:chk(<?=$list['Idx']?>)"></input></td>
				<td align=center><a
					href="javascript:movepage('detail.php','Idx','<?=$list['Idx']?>');"><?=$list['usercode']?>
				</a></td>
				<td><a
					href="javascript:movepage('detail.php','Idx','<?=$list['Idx']?>');"><b><?=$list['name']?>
					</b> </a></td>
				<td><?=$list['tel']?></td>
				<td><?=$list['phone']?></td>
				<td><?=$list['fax']?></td>
				<td><?=$list['addr1']?></td>
				<td><?=$list['email']?></td>
				<td><?=$list['job']?></td>
				<td><? 
						if($list['mw']=='m'){
							echo "남";
						}
						else{
							echo "여";
						}
						?>
				</td>
				</tr>	
<?php 
}
mysql_free_result($result);	
?>
		</table>
			<div style="float: left; padding: 0; margin: 0; width: 100%; background: #efefef; border-bottom: 1px solid #a2a2a2; height: 30px; padding-top: 3px;">
				<div style="float: right; text-align:right; width:20%;padding-right:15px;padding-top:3px;">
					<input type="text" name="sear_char" class="search" value="<?=$value?>"/><a href="javascript:search()"><img src="../../../image/search_btn.gif"/></a>
					<select size="1" name="scale" id="scale" onChange="javascript:search()" class="count">
	                    <option value="10" <?if($scale==10)echo "selected";?>>10</option>
	                    <option value="20" <?if($scale==20)echo "selected";?>>20</option>
	                    <option value="30" <?if($scale==30)echo "selected";?>>30</option>
	                    <option value="50" <?if($scale==50)echo "selected";?>>50</option>
	                    <option value="100" <?if($scale==100)echo "selected";?>>100</option>
	            	</select> 
				</div>
				<!-- 페이지 -->
				<div style="float: left;width:70%;">
					<div id="pager">
					</div>
				</div>
				<!-- 페이지 -->
			</div>
		</form>
	</div>
</body>
</html>